#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
营销方案生成系统后端服务启动脚本
"""

import os
import sys
from app import app

def main():
    """主函数"""
    print("="*50)
    print("营销方案生成系统后端服务")
    print("="*50)
    print("服务地址: http://localhost:5001")
    print("API文档:")
    print("  GET  /api/health - 健康检查")
    print("  POST /api/requirements - 提交需求")
    print("  GET  /api/requirements - 获取所有需求")
    print("  GET  /api/requirements/<id> - 获取单个需求")
    print("  POST /api/requirements/<id>/solutions - 保存方案")
    print("  GET  /api/requirements/<id>/solutions - 获取需求方案")
    print("="*50)
    print("按 Ctrl+C 停止服务")
    print("="*50)
    
    try:
        # 启动Flask应用
        app.run(
            debug=True,
            host='0.0.0.0',
            port=5001,
            use_reloader=True
        )
    except KeyboardInterrupt:
        print("\n服务已停止")
    except Exception as e:
        print(f"启动失败: {e}")
        sys.exit(1)

if __name__ == '__main__':
    main()